{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from pandas import Series, DataFrame\n",
    "\n",
    "s = pd.read_csv('../data/nyc-temps.txt').squeeze()\n",
    "df = DataFrame({'temp': s, \n",
    "                'hour': [0,3,6,9,12,15,18,21] * 91})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    728.000000\n",
       "mean      -1.050824\n",
       "std        5.026357\n",
       "min      -14.000000\n",
       "25%       -4.000000\n",
       "50%        0.000000\n",
       "75%        2.000000\n",
       "max       12.000000\n",
       "Name: temp, dtype: float64"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Get the mean + median for baseline data\n",
    "df['temp'].describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set temp at 3 and 6 a.m. to NaN\n",
    "df.loc[\n",
    "    df['hour'].isin([3, 6]),\n",
    "    'temp'\n",
    "] = np.NaN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Interpolate!\n",
    "df = df.interpolate()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count    728.000000\n",
       "mean      -1.050824\n",
       "std        5.026357\n",
       "min      -14.000000\n",
       "25%       -4.000000\n",
       "50%        0.000000\n",
       "75%        2.000000\n",
       "max       12.000000\n",
       "Name: temp, dtype: float64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Get the mean + median for when we're missing 3 and 6 a.m.\n",
    "df['temp'].describe()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
